foreign key django createview

39

class PhoneCreate(CreateView):
    model = Phone
    fields = ['number', 'type']

    def form_valid(self, form):
        form.instance.person_id = self.kwargs.get('pk')
        return super(PhoneCreate, self).form_valid(form)

Comments

Submit
0 Comments